/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Principal.java
 *
 * Created on 20-dic-2011, 10:50:50
 */
package invsys;

import invsys.Controladores.ControlProducto;
import invsys.Vistas.Inventario;
import invsys.Vistas.VistaCompra;
import invsys.Vistas.VistaCreditos;
import invsys.Vistas.VistaVenta;
import invsys.Vistas.vistaProveedor;
import invsys.Inicio.VistaLogin;
import invsys.Vistas.VistaListaVentas;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

/**
 *
 * @author luigie
 */
public class Principal extends javax.swing.JFrame {

VistaCompra vc= new VistaCompra(this, true);
vistaProveedor vp = new vistaProveedor();
VistaVenta vv = new VistaVenta(this, true);
Inventario inv = new Inventario();
VistaCreditos vcr=new VistaCreditos(this, rootPaneCheckingEnabled);
VistaListaVentas vl=new VistaListaVentas(this,true);

    /** Creates new form Principal */
    public Principal() {
        initComponents();
        codigo.setVisible(false);
        this.setLocationRelativeTo(null);
        iniciar();
        jPanel1.setLocation(Cerrarseccion.getLocation());
        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jToolBar1 = new javax.swing.JToolBar();
        barraCompra = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jDesktopPane1 = new invsys.Imagenes.Fondo.JDeskotPanel("fondo.jpg");
        jPanel1 = new invsys.Imagenes.Fondo.panel("fondo.gif");
        jTextField1 = new javax.swing.JTextField();
        jToolBar2 = new javax.swing.JToolBar();
        Usuario = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        Stockmin = new javax.swing.JButton();
        Cerrarseccion = new javax.swing.JButton();
        codigo = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu6 = new javax.swing.JMenu();
        MenuCompras = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        MenuVentas = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem3 = new javax.swing.JMenuItem();
        MenuInventario = new javax.swing.JMenu();
        jMenuItem4 = new javax.swing.JMenuItem();
        MenuConsultas = new javax.swing.JMenu();
        jMenuItem5 = new javax.swing.JMenuItem();
        MenuVariables = new javax.swing.JMenu();
        MenuUsuarios = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jToolBar1.setOrientation(javax.swing.SwingConstants.VERTICAL);
        jToolBar1.setRollover(true);

        barraCompra.setIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/ventas.png"))); // NOI18N
        barraCompra.setText("Comprar");
        barraCompra.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        barraCompra.setFocusable(false);
        barraCompra.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        barraCompra.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/venta3.png"))); // NOI18N
        barraCompra.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/venta.png"))); // NOI18N
        barraCompra.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        barraCompra.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                barraCompraActionPerformed(evt);
            }
        });
        jToolBar1.add(barraCompra);

        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/compra.png"))); // NOI18N
        jButton2.setText("Vender  ");
        jButton2.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButton2.setFocusable(false);
        jButton2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton2.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/compra2.png"))); // NOI18N
        jButton2.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/compra1.png"))); // NOI18N
        jButton2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        jToolBar1.add(jButton2);

        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/inventario.png"))); // NOI18N
        jButton3.setText("Iventario    ");
        jButton3.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButton3.setFocusable(false);
        jButton3.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton3.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/inventario2.png"))); // NOI18N
        jButton3.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/inventario1.png"))); // NOI18N
        jButton3.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });
        jToolBar1.add(jButton3);

        jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/Provedore.png"))); // NOI18N
        jButton4.setText("Provedores");
        jButton4.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButton4.setFocusable(false);
        jButton4.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton4.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/provedore2.png"))); // NOI18N
        jButton4.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/provedore1.png"))); // NOI18N
        jButton4.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });
        jToolBar1.add(jButton4);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 130, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 110, Short.MAX_VALUE)
        );

        jPanel1.setBounds(530, 40, 130, 110);
        jDesktopPane1.add(jPanel1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTextField1.setFont(new java.awt.Font("Berlin Sans FB", 1, 36)); // NOI18N
        jTextField1.setForeground(new java.awt.Color(51, 153, 0));
        jTextField1.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jTextField1.setText("$0234234");
        jTextField1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, new java.awt.Color(0, 0, 153), new java.awt.Color(0, 0, 0), new java.awt.Color(255, 255, 0), new java.awt.Color(204, 0, 0)), "Saldo En Caja", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION));
        jTextField1.setBounds(10, 10, 290, 70);
        jDesktopPane1.add(jTextField1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jToolBar2.setFloatable(false);
        jToolBar2.setRollover(true);

        Usuario.setFont(new java.awt.Font("Segoe Print", 1, 14));
        Usuario.setForeground(new java.awt.Color(0, 0, 204));
        Usuario.setIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/usuario.png"))); // NOI18N
        Usuario.setText("----");
        Usuario.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/usuario.png"))); // NOI18N
        Usuario.setEnabled(false);
        Usuario.setFocusable(false);
        jToolBar2.add(Usuario);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11));
        jToolBar2.add(jLabel1);

        jLabel2.setText("                                                                                                                                    ");
        jToolBar2.add(jLabel2);

        Stockmin.setText("jButton4");
        Stockmin.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        Stockmin.setFocusable(false);
        Stockmin.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        Stockmin.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        Stockmin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                StockminActionPerformed(evt);
            }
        });
        jToolBar2.add(Stockmin);

        Cerrarseccion.setText("Cerrar Sesion");
        Cerrarseccion.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        Cerrarseccion.setFocusable(false);
        Cerrarseccion.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        Cerrarseccion.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        Cerrarseccion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CerrarseccionActionPerformed(evt);
            }
        });
        jToolBar2.add(Cerrarseccion);

        codigo.setForeground(new java.awt.Color(0, 0, 153));
        codigo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        codigo.setText("-----------");
        codigo.setEnabled(false);
        jToolBar2.add(codigo);

        jMenu6.setText("♦♦♦©♦♦♦");
        jMenu6.setEnabled(false);
        jMenuBar1.add(jMenu6);

        MenuCompras.setText("Proveedor");

        jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F4, 0));
        jMenuItem1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/proveedor1.png"))); // NOI18N
        jMenuItem1.setText("Registrar Proveedor");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        MenuCompras.add(jMenuItem1);

        jMenuBar1.add(MenuCompras);

        MenuVentas.setText("Ventas");

        jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F2, 0));
        jMenuItem2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/Vender.png"))); // NOI18N
        jMenuItem2.setText("Vender");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        MenuVentas.add(jMenuItem2);

        jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F5, 0));
        jMenuItem3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/Cobrar.png"))); // NOI18N
        jMenuItem3.setText("Cobrar");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        MenuVentas.add(jMenuItem3);

        jMenuBar1.add(MenuVentas);

        MenuInventario.setText("Inventario");

        jMenuItem4.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F3, 0));
        jMenuItem4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/inv.png"))); // NOI18N
        jMenuItem4.setText("Ver Inventario");
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem4ActionPerformed(evt);
            }
        });
        MenuInventario.add(jMenuItem4);

        jMenuBar1.add(MenuInventario);

        MenuConsultas.setText("Consultas");

        jMenuItem5.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F2, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/calendario.png"))); // NOI18N
        jMenuItem5.setText("Buscar Ventas");
        jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem5ActionPerformed(evt);
            }
        });
        MenuConsultas.add(jMenuItem5);

        jMenuBar1.add(MenuConsultas);

        MenuVariables.setText("Variables");
        jMenuBar1.add(MenuVariables);

        MenuUsuarios.setText("Control Usuario");
        jMenuBar1.add(MenuUsuarios);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jToolBar2, javax.swing.GroupLayout.DEFAULT_SIZE, 745, Short.MAX_VALUE)
                    .addComponent(jDesktopPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 745, Short.MAX_VALUE)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 433, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jToolBar2, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jDesktopPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 387, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void CerrarseccionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CerrarseccionActionPerformed
     VistaLogin login=new VistaLogin();
        this.dispose();    
    login.setVisible(true);
       
    }//GEN-LAST:event_CerrarseccionActionPerformed

    private void barraCompraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_barraCompraActionPerformed
        vc.Iniciar();
        vc.setVisible(true);
    }//GEN-LAST:event_barraCompraActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
         vp.setVisible(true);
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
       vv.usuario();
       vv.Listar();
        vv.setVisible(true);
    }//GEN-LAST:event_jButton2ActionPerformed

    private void StockminActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_StockminActionPerformed
 inv.jTabbedPane1.setEnabledAt(1,true);
 inv.jTabbedPane1.setEnabledAt(0,false);
 inv.jTabbedPane1.setSelectedIndex(1);
 inv.setVisible(true);
// TODO add your handling code here:
    }//GEN-LAST:event_StockminActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        vv.usuario();
        vv.Listar();
        vv.setVisible(true);
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
      
        vcr.setVisible(true);
        
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItem3ActionPerformed

    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
           inv.Iniciar(); 
        inv.setVisible(true);
        
    }//GEN-LAST:event_jMenuItem4ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
       inv.Iniciar();
        inv.setVisible(true);
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
 vp.setVisible(true);
 // TODO add your handling code here:
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
vl.setVisible(true);       
// TODO add your handling code here:
    }//GEN-LAST:event_jMenuItem5ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
    

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Principal().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Cerrarseccion;
    public static javax.swing.JMenu MenuCompras;
    private javax.swing.JMenu MenuConsultas;
    private javax.swing.JMenu MenuInventario;
    public static javax.swing.JMenu MenuUsuarios;
    public static javax.swing.JMenu MenuVariables;
    private javax.swing.JMenu MenuVentas;
    public static javax.swing.JButton Stockmin;
    public static javax.swing.JButton Usuario;
    public static javax.swing.JButton barraCompra;
    public static javax.swing.JLabel codigo;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JDesktopPane jDesktopPane1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JMenu jMenu6;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JToolBar jToolBar2;
    // End of variables declaration//GEN-END:variables
public static void iniciar(){
        try {
            String stock=ControlProducto.ProductoStockmin().toString();
            Stockmin.setToolTipText("hay "+stock+" productos  que Se Esta Agotando");
            Stockmin.setText(stock);
        } catch (Exception ex) {
            Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
        }
}
}
